package com.project.medical.sys.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.project.medical.sys.common.utils.PageUtils;
import com.project.medical.sys.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.project.medical.sys.entity.PatientEntity;
import com.project.medical.sys.service.PatientService;




/**
 * 
 *
 * @author wjl
 * @email ${email}
 * @date 2021-06-20 11:37:28
 */
@RestController
@RequestMapping("sys/patient")
public class PatientController {
    @Autowired
    private PatientService patientService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("sys:patient:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = patientService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("sys:patient:info")
    public R info(@PathVariable("id") Integer id){
		PatientEntity patient = patientService.getById(id);

        return R.ok().put("patient", patient);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("sys:patient:save")
    public R save(@RequestBody PatientEntity patient){
		patientService.save(patient);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("sys:patient:update")
    public R update(@RequestBody PatientEntity patient){
		patientService.updateById(patient);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("sys:patient:delete")
    public R delete(@RequestBody Integer[] ids){
        boolean b = patientService.removePatientByIds(Arrays.asList(ids));
        if (b){
            return R.ok("删除成功");
        }
        return R.error("删除失败");


    }

}
